package love.yuanmengrobot.guoyitang.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import love.yuanmengrobot.guoyitang.vo.MyRegisterVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MyRegisterMapper extends BaseMapper<MyRegisterVo> {

    @Select(" SELECT ss.REGISTER_TYPE," +
            "               ss.REGISTER_DATE," +
            "               ss.REGISTER_COUNT," +
            "               rref.REGISTER_NUM," +
            "               rref.SOURCE," +
            "               ss.STATUS," +
            "               doc.DOCTOR_NAME," +
            "               doc.DEPT_CODE," +
            "               pat.PATIENT_NAME," +
            "               hosp.HOSPITAL_NAME" +
            "        FROM tb_natmeha_register_ref  rref" +
            "            left join" +
            "                tb_natmeha_signal_source  ss" +
            "                    on rref.SOURCE_CODE=ss.itemCode" +
            "            left join" +
            "                tb_natmeha_doctor doc" +
            "                    on ss.DOCTOR_CODE=doc.itemCode" +
            "            left join" +
            "                tb_natmeha_patient pat" +
            "                    on rref.PATIENT_CODE=pat.itemCode" +
            "            left join" +
            "                tb_natmeha_hospital hosp" +
            "                    on doc.ORG_CODE = hosp.itemCode" +
            "        where rref.USER_CODE=#{itemCode}" +
            "        order by ss.REGISTER_DATE desc ")
    List<MyRegisterVo> selectMyRegister(Page page,@Param("itemCode")String itemCode);


}
